<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>欢迎进入登录页面</title>
    <link rel="stylesheet" type="text/css" href="/themes/default/easyui.css">
    <link rel="stylesheet" type="text/css" href="/themes/icon.css">
    <script type="text/javascript" src="/jquery.min.js"></script>
    <script type="text/javascript" src="/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="/locale/easyui-lang-zh_CN.js"></script>
</head>
<body>
    <h1>欢迎进入登录页面</h1>
    <form>
        <label for="username">登录账号:</label>
        <input type="text" id="username" name="username" placeholder="请输入登录账号"><br><br>
        <label for="password">登录密码:</label>
        <input type="text" id="password" name="password" placeholder="请输入登录密码"><br><br>
        <input type="button" value="登录" onclick="loginUser()">
    </form>
    <br><br>
    <input type="button" value="注册账号" onclick="insertUser()">
    <br><br>
    <input type="button" value="忘记密码？" onclick="forgetPassword()">
</body>
<script type="text/javascript">
    function loginUser(){
        let username = $("#username").val();
        let password = $("#password").val();

        let user = {
            username: username,
            password : password
        };
        let newUser = JSON.stringify(user);

        $.ajax({
            url: "/login/loginUser",
            type: "post",
            data: newUser,
            dataType: 'json',
            contentType:'application/json;charset=utf-8',
            success: function (data){
                if (data === 1) {
                    alert("登录失败!请重新校验账号密码");
                    location.reload();
                }else {
                    alert("欢迎登录!")
                    location.href="/boot/index.html";
                }
            }
        })
    }

    function insertUser(){
        location.href="/login/register.html";
    }
</script>
</html>
